package com.tg.sieve_data.controller.sys;

public class UserIdHolder {
    private static final ThreadLocal<Long> userIdThreadLocal = new ThreadLocal<>();
    /**
     * 设置当前用户的 userId
     * @param userId 用户 ID
     */
    public static void setUserId(Long userId) {
        userIdThreadLocal.set(userId);
    }

    /**
     * 获取当前用户的 userId
     * @return 用户 ID
     */
    public static Long getUserId() {
        return userIdThreadLocal.get();
    }

    /**
     * 清除当前用户的 userId
     */
    public static void clear() {
        userIdThreadLocal.remove();
    }
}
